using System;

/// <summary>
/// 
/// </summary>
namespace FamilyTree_v1._0
{
    public class Node
    {
        private Person data;

        public Person Data
        {
            get { return data; }
            set { data = value; }
        }

        private Node parentNode;

        public Node ParentNode
        {
            get { return parentNode; }
            set { parentNode = value; }
        }

        private Node leftNode;

        public Node LeftNode
        {
            get { return leftNode; }
            set { leftNode = value; }
        }

        private Node rightNode;

        public Node RightNode
        {
            get { return rightNode; }
            set { rightNode = value; }
        }
        public Node()
        {

        }
        public Node(Person aPerson)
        {
            this.Data = aPerson;
            this.LeftNode = this.RightNode = null;
        }
        public Node(Person aPerson, Node aLeftNode, Node aRightNode)
        {
            this.Data = aPerson;
            this.LeftNode = aLeftNode;
            this.RightNode = aRightNode;
        }
        public Node(Person aPerson, Node aParentNode, Node aLeftNode, Node aRightNode)
        {
            this.Data = aPerson;
            this.parentNode = aParentNode;
            this.LeftNode = aLeftNode;
            this.RightNode = aRightNode;
        }
        public Boolean IsEmpty()
        {
            return this.Data == null;
        }
        public int Size()
        {
            return this.IsEmpty() ? 0 : 1 + this.LeftNode.Size() + this.RightNode.Size();
        }
        public Node FirstNode()
        {
            return this.LeftNode.IsEmpty() ? this : this.LeftNode.FirstNode();
        }
        public void DeleteLastNode()
        {
            if (this.RightNode.RightNode.IsEmpty())
            {
                this.RightNode = this.RightNode.LeftNode;
            }
            else
            {
                this.RightNode.DeleteLastNode();
            }
        }
    }
}